package com.ray.service;

import com.ray.dao.StudentDao;
import com.ray.dao.UserDao;
import com.ray.pojo.Student;
import com.ray.pojo.User;
import com.ray.utils.SqlSessionUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class StudentServiceImpl implements StudentService
{
    /**
     * @param id
     * @return
     */
    @Override
    public Student getStudent(int id)
    {
        try (SqlSession sqlSession = SqlSessionUtil.getSqlSession())
        {
            StudentDao mapper = sqlSession.getMapper(StudentDao.class);
            Student student = mapper.getStudent(id);
            return student;
        }
    }

    /**
     * @return
     */
    @Override
    public List<Student> getStudentList()
    {
        try (SqlSession sqlSession = SqlSessionUtil.getSqlSession())
        {
            StudentDao mapper = sqlSession.getMapper(StudentDao.class);
            List<Student> studentList = mapper.getStudentList();
            return studentList;
        }
    }
}
